home *** CD-ROM | disk | FTP | other *** search
/ Nejlepší hry / Nejlepsi hry.iso / hry / sea of chaos / sea_install.msi / _15C39AAA7726369D39812BD40F01CF6A / _4459DEF3A62245078ED2A81EF23C18BE < prev    next >
Text File  |  2005-03-09  |  1KB  |  49 lines

  1. ///basic particle shader
  2. //input should be 4 points that are the same, tex coord will expand them in screen space
  3. //Luke Lenhart
  4. //(C)2004-2005 Digipen Institute of Technology
  5.  
  6. //world,view,projection transform
  7. float4x4 matViewProj;
  8.  
  9. //camera position in world space
  10. float4 cameraPos;
  11.  
  12. //particle size modifier
  13. float size;
  14.  
  15. //shader input
  16. struct VS_INPUT
  17. {
  18.     float4 Pos : POSITION;
  19.     float4 Color : COLOR;
  20.     float2 Tex0 : TEXCOORD0;
  21. };
  22.  
  23. //shader output
  24. struct VS_OUTPUT
  25. {
  26.     float4 Pos : POSITION;
  27.     float4 Color : COLOR;
  28.     float2 Tex0 : TEXCOORD0;
  29. };
  30.  
  31. //shader code
  32. VS_OUTPUT VShader(VS_INPUT In)
  33. {
  34.     VS_OUTPUT Out;
  35.     
  36.     //transform pos and copy tex coord and color over
  37.     Out.Pos=mul(matViewProj,In.Pos);
  38.     Out.Tex0=In.Tex0;
  39.     Out.Color=In.Color;
  40.     
  41.     //expand outwards from center point, based on distance and tex coord
  42.     float dist=distance(cameraPos,In.Pos);
  43.     
  44.     Out.Pos.xy+=(1.0f/sqrt(dist))*(In.Tex0-0.5f)*size;
  45.  
  46.     //spit out the results
  47.     return Out;
  48. }
  49.